<template>
  <div class="recordDetail">
    <Navbar :appTitle="$route.meta.title" @ClickRight="ClickRight"/>
    <!--头部-->
    <div class="d-head">
      <div class="content">
        <div class="left">
          <div class="title">{{ detailInfo.entryCode }}</div>
          <div class="row">
            入库类型：<span style="color:#191f25">{{
              detailInfo.inWarehouseTypeName || "--"
            }}</span>
          </div>
          <div class="row">
            送入人：<span style="color:#191f25">{{
              detailInfo.sendPersionName || "--"
            }}</span>
          </div>
          <div class="row">
            入库时间：<span style="color:#191f25">{{
              detailInfo.inWarehouseTime || "--"
            }}</span>
          </div>
          <!-- <div class="row" v-if="detailInfo.inWarehouseType == '1'">
            生产工单：<span style="color:#191f25">{{
              detailInfo.orderCode || "--"
            }}</span>
          </div>
          <div class="row" v-if="detailInfo.inWarehouseType == '2'">
            销售订单：<span style="color:#191f25">{{
              detailInfo.orderCode || "--"
            }}</span>
          </div> -->
        </div>
      </div>
    </div>
    <van-tabs v-model="active" :offset-top="158" line-width="150px" color="#1890FF">
      <van-tab title="入库物品明细" >
        <div class="list" :style="{height: (detailInfo.inWarehouseType != 1 && detailInfo.inWarehouseType != 2) ? '65vh' : '65vh'}" v-if="entryDetails && entryDetails.length != 0">
          <div
            v-for="(item, index) in entryDetails"
            :key="index"
            class="wrap"
          >
            <div class="top">
              <div class="icon"></div>
              <div class="title">
                {{ item.serialNumber }} | {{
                  item.serialName
                }}
              </div>
            </div>
            <div class="center">
              <div>
                <p>
                  <span class="key">规格：</span>
                  <span class="value">{{ item.serialSpecifications || '-' }}</span>
                </p>
                <p>
                  <span class="key">单位：</span>
                  <span class="value">{{ item.unitName  || '-' }}</span>
                </p>
                <p>
                  <span class="key">数量：</span>
                  <span class="value">{{ item.inWarehouseNum  || '-' }}</span>
                </p>
              </div>
            </div>
          </div>
        </div>
        <van-empty v-else description="入库物品明细为空" />
      </van-tab>

      <van-tab title="自定义信息">
        <div class="list" :style="{height: (detailInfo.inWarehouseType != 1 && detailInfo.inWarehouseType != 2) ? '65vh' : '65vh'}" v-if="detailInfo.extDataJson && detailInfo.extDataJson.length != 0">
            <div class="wrap">
              <div class="center">
              <p v-for="(item, index)  in detailInfo.extDataJson" :key="index">
                <span class="key fontAno">{{item.fieldName}} </span>
                <span class="value fontAno">{{ item.fieldValue }}</span>
              </p>
              </div>
            </div>
        </div>
        <van-empty v-else description="自定义字段为空" />
      </van-tab>
    </van-tabs>
  </div>
</template>

<script>
import Navbar from "@/components/navBar/navBar_right";
import pageList from "@/components/pageList";
import { 
  inventoryOrderDetail,
  inventoryOrderDetailList,
  formTypeExtendedFieldList,
} from "@/api/mobile";
import store from '@/store'

export default {
  name: "inventoryOrderDetail", //入库单详情
  components: { Navbar, pageList },
  data() {
    return {
      active: 0,
      detailInfo: {},
      entryDetails: [],
      formTypeExtendedFields: [],
    };
  },
  computed: {},
  mounted() {},
  created() {
    store.commit('SET_CURRENT_PREFIX', '/jksaas-produce/produce')
    this.getDetail();
  },
  methods: {
    async getDetail() {
      // 获取出入库自定义表单字段;
      await formTypeExtendedFieldList({formType: 5}).then((res) => {
        if(res.code == 200 && res.result) {
          this.formTypeExtendedFields = res.result
        }
      });

      let id = this.$route.query.id;
      inventoryOrderDetail({id: id}).then((res) => {
        if (res.code == 200 && res.result) {
          this.detailInfo = res.result;
          for(const item in this.detailInfo.extDataJson) {
            this.formTypeExtendedFields.map((ele) => {
              if(ele.fieldKey == item) {
                ele.fieldValue = this.detailInfo.extDataJson[item]
              }
            })
          }
          this.detailInfo.extDataJson = this.formTypeExtendedFields
        } else {
          this.$toast(res.message);
        }
      });
      inventoryOrderDetailList({entryId: id, inOutType: 0}).then((res) => {
        if (res.code == 200 && res.result) {
          this.entryDetails = res.result.records;
        } else {
          this.$toast(res.message);
        }
      });
    },
    ClickRight() {
      this.$router.push({
        path: "/application",
      });
    },
  },
};
</script>
<style lang="scss" scoped>
.recordDetail {
  height: 100vh;
  overflow: hidden;
  .d-head {
    width: 100%;
    padding: 32px;
    background: #ffffff;
    .content {
      display: flex;
      justify-content: space-between;
      align-items: center;
      .left {
        flex: 1;
        .title {
          font-size: 32px;
          font-family: PingFang SC;
          font-weight: 500;
          color: #191f25;
          line-height: 32px;

          overflow: hidden;
          white-space: nowrap;
          text-overflow: ellipsis;
          -o-text-overflow: ellipsis;
        }
        .row {
          font-size: 28px;
          font-family: PingFang SC;
          font-weight: 400;
          color: #888888;
          margin-top: 20px;
        }
      }
      .right {
        flex: 1;
        .rightImg {
          display: block;
          width: 55px;
          height: 55px;
          //   margin-left: 0.45rem;
          // border: 1px solid blue;
        }
      }
    }
  }

  .otherTaps {
    background: #ffffff;
    padding: 32px;
    margin-top: 20px;
    .title {
      padding-bottom: 20px;
      border-bottom: 1px solid #eeeeee;
      .icon {
        display: inline-block;
        width: 6px;
        height: 28px;
        background: #1890ff;
      }
      .content {
        width: 126px;
        height: 32px;
        font-size: 32px;
        font-family: PingFang SC;
        font-weight: bold;
        color: #191f25;
        line-height: 44px;
        margin-left: 20px;
      }
    }
    .content {
      .row {
        font-size: 28px;
        font-family: PingFang SC;
        font-weight: 400;
        margin-top: 32px;
        display: flex;
        .r-label {
          color: #888888;
          display: block;
          // width: 0.7rem;
          //   border: 1px solid red;
        }
        .r-column {
          display: block;
          color: #191f25;
          width: 500px; 
          //   border: 1px solid red;
          //    width: 1rem;
        }
      }
      .fhrow {
        display: flex;
        .fhImg {
          width: 0.55rem;
          height: 0.55rem;
          border-radius: 0.1rem;
        }
        .rt-column {
          width: 2.55rem;
          //   height: 2.55rem;
          margin-left: 0.2rem;
          .rt-title {
            font-size: 0.16rem;
            font-family: PingFang SC;
            font-weight: 500;
            color: #191f25;
            margin-bottom: 0.16rem;
          }
          .rt-row {
            display: flex;
            justify-content: space-between;
            margin-bottom: 0.23rem;
            .column {
              //    border: 1px solid red;
              width: 1.5rem;
              .column-t {
                font-size: 0.14rem;
                font-family: PingFang SC;
                font-weight: 400;
                color: #888888;
                display: block;
                width: 100%;
                margin-bottom: 0.03rem;
              }
              .column-c {
                font-size: 0.16rem;
                font-family: PingFang SC;
                font-weight: 400;
                color: #191f25;
                display: block;
                width: 100%;
              }
            }
          }
        }
      }
    }
  }
  .search-bottom {
    height: 0.5rem;
    width: 100%;
    background: #ffffff;
    // background: red;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: fixed;
    bottom: 0px;
    padding: 0.11rem;
    .btnconfirm {
      width: 1.72rem;
      height: 0.39rem;
      background: #1890ff;
      border-radius: 0rem;
      text-align: center;
      line-height: 0.39rem;
      color: #ffffff;
    }
    .btncancel {
      width: 1.72rem;
      height: 0.39rem;
      background: #f6f6f6;
      border: 0.01px solid rgba(25, 31, 37, 0.12);
      border-radius: 0rem;
      text-align: center;
      line-height: 0.39rem;
    }
  }
}
.contentBox {
  margin-top: 1.38rem;
}

.otherMargin {
  height: 0.1rem;
  background: #f5f5f5;
}
.bottomLine {
  height: 0.01rem;
  background-color: #f0f0f0;
  margin: 0.16rem 0.16rem 0 0.06rem;
}
.ExamineBottom {
  height: 0.5rem;
}
.status {
  display: inline-block;
  margin-top: 0.16rem;
  padding: 0.03rem 0.08rem;
  background: #edf6ff;
  border-radius: 0.02rem;
  font-size: 0.11rem;
  font-family: PingFang SC;
  font-weight: 400;
  color: #3774ac;
}
.list {
  height: 65vh;
  overflow: scroll;
  .wrap {
    background: #fff;
    margin: 24px 0;
    padding: 30px;
    width: 100vw;
    .top {
      display: flex;
      justify-content: flex-start;
      .icon {
        width: 6px;
        height: 36px;
        background: #1890ff;
        margin-top: 6px;
        margin-right: 20px;
      }
      .title {
        width: 620px;
        margin-right: 20px;
        font-size: 32px;
        font-family: PingFang SC;
        font-weight: 500;
        color: #191f25;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
      .spot img {
        width: 40px;
        height: 40px;
      }
    }
    .center {
      p {
        margin: 16px 25px;
        font-size: 28px;
        display: flex;
        position: relative;
        .key {
          color: #888888;
        }
        .value {
          color: #191f25;
          width: 380px;
          display: block;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
        }
        .arrow {
          color: #1890ff;
          // float: right;
          // margin-right: -0.05rem;
          // display: block;
          position: absolute;
          right: -10px
        }      
        .fontAno {
          font-size: 30px;
          padding-left: 20px;
        }
      }
      .showAll {
        background: #f5f8ff;
        width: 100vw;
        margin-left: -0.15rem;
        padding: 0.15rem;
        margin-bottom: 0.15rem;
      }
    }
    .label {
      margin-left: -0.03rem;
      margin-top: -0.1rem;
      span {
        height: 0.16rem;
        background: #f0f6fe;
        color: #1890ff;
        margin-right: 0.1rem;
        padding: 0.03rem 0.08rem;
        font-size: 0.11rem;
        border-radius: 0.03rem;
      }
    }
    .foot {
      // height: 0.33rem;
      // line-height: 0.33rem;
      display: flex;
      justify-content: space-between;
      // margin: 0.15rem 0.12rem 0 0.12rem;
      font-size: 0.14rem;
      .pictures {
        width: 0.33rem;
        height: 0.33rem;
        line-height: 0.33rem;
        text-align: center;
        color: #fff;
        background: #1890ff;
        display: block;
        border-radius: 0.06rem;
        font-size: 0.12rem;
        margin-right: 0.1rem;
      }
      .text {
        width: 1rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
      .opera {
        color: #1890ff;
        font-size: 0.14rem;
      }
    }
  }
}
</style>
